package mysql

import "gorm.io/gorm"

type Settlement struct {
	gorm.Model
	UserId            int     `gorm:"type:int(20);not null;comment:'用户id'"`
	MealProductsId    int     `gorm:"type:int(20);not null;comment:'餐品id'"`
	MealProductsName  string  `gorm:"type:varchar(100);not null;comment:'餐品名称'"`
	MealProductsPrice float64 `gorm:"type:double(10,2);not null;comment:'餐品价格'"`
	MealProductsScore float64 `gorm:"type:double(10,2);not null;comment:'餐品评分'"`
	MealProductsInter string  `gorm:"type:varchar(100);not null;comment:'餐品描述'"`
	MealProductsImage string  `gorm:"type:varchar(255);not null;comment:'产品图片'"`
	MealProductsNotes string  `gorm:"type:varchar(255);not null;comment:'备注'"`
	Price             float64 `gorm:"type:double(10,2);not null;comment:'总价格'"`
	TableNum          string  `gorm:"type:varchar(100);not null;comment:'桌号'"`
}

func SettlementCreate(settlement *Settlement) error {
	return DB.Debug().Create(&settlement).Error
}

func SettlementShow(id int64) (result *Settlement, err2 error) {
	DB.Debug().Where("id = ?", id).Limit(1).Find(&result)
	return
}
